package com.mo.controller;

import cn.hutool.core.util.IdUtil;
import com.mo.entity.People;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Metrics;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author moon.pan
 * @program mo-all
 * @apiNote
 * @since 2022/3/25
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private MeterRegistry meterRegistry;

    @Autowired
    private People woman;

    @SneakyThrows
    @GetMapping
    public String action(){
        Thread.sleep(5000);
        Metrics.counter("http.get.action").increment();
        Counter.builder("spring.get.action").register(meterRegistry).increment();
        return IdUtil.objectId();
    }

}
